package com.twu.bibilioteca;

/**
 * Created by IntelliJ IDEA.
 * User: dixithk
 * Date: 6/20/14
 * Time: 8:51 AM
 * To change this template use File | Settings | File Templates.
 */
public class CheckOutMovie implements MenuOperations {


    UserInterface ui = new UserInterfaceApp();
    Library lib = new Library();

    public CheckOutMovie(UserInterface ui, Library lib) {
        this.ui = ui;
        this.lib = lib;
    }

    @Override
    public Result action() {



        Movie movieNeedToBeCheckedOut =  lib.GiveMovieObjectFromTitle(ui.takeInputFromUserFromCheckOutMovie());
        if(movieNeedToBeCheckedOut!=null && (!lib.isMovieAvailableForCheckOut(movieNeedToBeCheckedOut)))
        {
            movieNeedToBeCheckedOut.markAsCheckedOut();

            return  new Result("Thank you Enjoy the movie at Home  " , true);




        }
        else
        {
            return new Result("That movie is not available." ,false);
        }

        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public String getName() {
        return "check out a Movie";  //To change body of implemented methods use File | Settings | File Templates.
    }
}
